﻿<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of sidebarclass
 *
 * @author Дмитрий
 */
class sidebar {
    private $widgets = array();

    public function __construct($widgets_list){
        $w = explode(';', $widgets_list);
        foreach($w as $val){
            $this->add_widget($val);
        }
    }

    public function add_widget($widget){
        $cw = new $widget();
        if($cw->isWidget){
            array_push($this->widgets, $cw);
        }
    }

    public function print_widgets(){
        foreach($this->widgets as $w){
            //for designer - some parts a here
            echo "<!-- widget ".strtoupper(get_class($w))." output started -->\n";
            echo "<div class=\"widget\">\n";
            echo " <div class=\"widget_header\">$w->header</div>\n";
            echo " <div class=\"widget_body\">";
            $w->widget_print();
            echo "</div>";
            echo "</div>\n";
            echo "<!-- widget ".strtoupper(get_class($w))." output finished -->\n";
        }
    }
}
?>
